package com.zbkj.service.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

import java.util.concurrent.ThreadPoolExecutor;

/**
 * @ClassName: ThreadPoolConfig
 * @Description: TODO
 * @Author: fanbing
 * @Date: 2024/6/29 17:57
 * @Version: V1.0
 **/
@Configuration
public class ThreadPoolConfig {


    @Bean("monitorChannelThreadPool")
    public ThreadPoolTaskExecutor monitorChannelThreadPool() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(6);// 核心线程数
        executor.setMaxPoolSize(10); //最大线程数
        executor.setQueueCapacity(100);//队列容量
        executor.setKeepAliveSeconds(60);//线程活跃时间
        executor.setThreadNamePrefix("monitorChannelThreadPool-");
        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); // 设置拒绝策略
        executor.initialize();
        return executor;
    }



}
